package com.lin.bank.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * mq配置类
 *
 * @author Li
 * @date 2022/04/07
 */
@Configuration
public class RabbitMQConfig {


    @Bean("queueA")
    public Queue queueA() {
        return QueueBuilder.durable("queueA").build();
    }

    // 声明 xExchange
    @Bean("xExchange")
    public DirectExchange xExchange() {
        return new DirectExchange("xExchange");
    }

    // 声明队列 A 绑定 X 交换机
    @Bean
    public Binding queueaBindingX(@Qualifier("queueA") Queue queueA,
                                  @Qualifier("xExchange") DirectExchange xExchange) {
        return BindingBuilder.bind(queueA).to(xExchange).with("");
    }


}
